package com.wolfpire.workflow.cmd;

import org.hibernate.Session;
import org.jbpm.api.cmd.Environment;
import org.jbpm.pvm.internal.cmd.AbstractCommand;

import com.wolfpire.workflow.om.JbpmTask;


public class UpdateJbpmTaskCmd extends AbstractCommand<JbpmTask> {

	/**
	 * 
	 */
	private static final long serialVersionUID = -2884628497293869883L;
	
	protected JbpmTask jbpmTask;
	
	public UpdateJbpmTaskCmd(JbpmTask jbpmTask) {
		this.jbpmTask = jbpmTask;
	}

	public JbpmTask execute(Environment environment) throws Exception {
		Session session = environment.get(Session.class);				
		if (null != jbpmTask) {
			session.update(jbpmTask);			
			return (JbpmTask)session.get(JbpmTask.class, jbpmTask.getDbId());
		}	
		return null;
	}

}
